'''
Created on 2010-3-3

@author: Administrator
'''
import sys
from jolly.datastructures.PrePostVisitor import PrePostVisitor

class PostOrder(PrePostVisitor):
    '''
    Adapter to convert a Visitor to a PrePostVisitor for post-order traversal.
    '''


    def __init__(self, visitor):
        '''
        (PostOrder, Visitor) -> None
        Constructs a post-order visitor from the given visitor.
        '''
        super(PostOrder, self).__init__()
        self._visitor=visitor
    
    def postVisit(self, obj):
        '''
        (PostOrder, Object) -> None
        Post-visits the given object.
        '''
        self._visitor.visit(obj)
    
    def getIsDone(self):
        '''
        (PostOrder) -> bool
        Returns true if the visitor is done.
        '''
        return self._visitor.isDone
    
    @staticmethod
    def main(*argv):
        "PostOrder test program."
        print PostOrder.main.__doc__
        return 0

if __name__=="__main__":
    sys.exit(PostOrder.main(*sys.argv))
        